<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: mi
  Date: 2019/5/24
  Time: 15:43
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page isELIgnored="false" %>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title></title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/mater.min.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/vendor.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/styles.css">
    <link rel="shortcut icon" href="${pageContext.request.contextPath}/images/favicon.png">
    <script src="${pageContext.request.contextPath}/js/jquery2.js"></script>
</head>
<body>
<div class="card-body">
    <form id="groupFrom">
        <div class="form-group">
            <label for="dbian">部门编号</label>
            <input type="text" class="form-control" name="dbian" id="dbian">
        </div>
        <div class="form-group">
            <label for="dname">部门名称</label>
            <input type="text" class="form-control" id="dname" name="dname">
        </div>
        <div class="form-group">
            <label for="pid">上级部门</label>
            <select class="form-control" id="pid" name="pid">
                <option value="">--请选择--</option>
            </select>
        </div>
        <div class="form-group">
            <label>部门负责人</label>
            <input type="text" class="form-control" name="dmanager" id="dmangager">
        </div>
        <div class="form-group">
            <label for="dtel">部门电话</label>
            <input type="text" class="form-control" id="dtel" name="dtel">
        </div>
        <div class="form-group">
            <label for="dfax">部门传真</label>
            <input type="text" class="form-control" id="dfax" name="dfax">
        </div>
        <div class="form-group">
            <label for="demail">部门邮箱</label>
            <input type="email" class="form-control" id="demail" name="demail"/>
        </div>
        <div class="form-group">
            <label for="duty">部门职责</label>
            <input class="form-control" id="duty" name="duty"/>
        </div>
    </form>
    <button class="btn btn-gradient-primary mr-2" id="groupBtn">确认合并</button>
</div>
<script>
    $(function () {
        $.ajax({
            type: "get",
            url: "positionController/queryPositionAll",
            dataType: "json",
            success: function (msg) {
                $.each(msg, function (index, data) {
                    var options = "<option value='" + data.id + "'>" + data.wname + "</option>";
                    $("#pid").append(options);
                });
            },
            error: function () {
                window.location.href = "404.jsp";
            }
        });

        $("#groupBtn").click(function () {
            var dept = $("#groupFrom").serialize();
            $.ajax({
                type: "post",
                url: "dept/stratGroupDept",
                data: dept,
                dataType: "",
                success: function (msg) {
                    window.location.href = "showDeptData.jsp";
                },
                error: function () {
                    window.location.href = "404.jsp";
                }
            })
        });
    });
</script>
</body>
</html>